package Java.BlackHorse.Thread.waitANDnotify;

public class Cook extends Thread{
    @Override
    public void run() {
        while(true){
            synchronized(Dest.lock){
                if(Dest.count == 0){
                    break;
                }else{
                    if(Dest.foodFlag == 1){
                        try {
//                            等待吃货把面吃完
                            Dest.lock.wait();
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }else{
                        System.out.println("厨师做了一碗面");
                        Dest.foodFlag = 1;
//                        唤醒吃货来吃面
                        Dest.lock.notifyAll();
                    }
                }
            }
        }
    }
}
